package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateAdInfoGetPageDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateSaveAdInfoDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateUpdateAdInfoDTO;
import com.itlong.cloud.POJO.VO.operate.OperateAdGetOneVO;
import com.itlong.cloud.POJO.VO.operate.OperateAdImgVO;
import com.itlong.cloud.POJO.VO.operate.OperateAdVO;
import com.itlong.cloud.operate.service.IOperateAdManageService;
import com.itlong.cloud.project.operate.IOperateAdManageServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <desc>
 *      运营-运营管理-广告管理暴露接口实现类。
 * <desc/>
 *
 * @createDate 2017/10/10.
 */
@RestController
public class OperateAdManageServiceResource implements IOperateAdManageServiceClient {

    @Autowired
    IOperateAdManageService iOperateAdManageService;

     /**
      * <desc>
      *      保存广告信息。
      * <desc/>
      *
      * @param  adInfoDTO 请求参数
      * @return
      * @author shengen.T
      * @createDate 2017/10/16
      */
    @Override
    @RequestMapping(path = "/operate/marketer/ad/saveAd", method = {RequestMethod.POST})
    public Integer saveAd(@RequestBody OperateSaveAdInfoDTO adInfoDTO) throws Exception{
        return iOperateAdManageService.saveAdInfo(adInfoDTO);
    }

    /**
     * <desc>
     *      修改广告信息。
     * <desc/>
     *
     * @param  adInfoDTO 请求参数
     * @return
     * @author shengen.T
     * @createDate 2017/10/16
     */
    @Override
    @RequestMapping(path = "/operate/marketer/ad/updateAd", method = {RequestMethod.POST})
    public Integer updateAd(@RequestBody OperateUpdateAdInfoDTO adInfoDTO) throws Exception{
        return iOperateAdManageService.updateAdInfo(adInfoDTO);
    }

     /**
      * <desc>
      *      批量发布广告信息。
      * <desc/>
      *
      * @param  adIds 广告ID列表
      * @return
      * @author shengen.T
      * @createDate 2017/10/17
      */
    @Override
    @RequestMapping(path="/operate/marketer/ad/publishAd/{adIds}",method = {RequestMethod.GET})
    public Integer publishAd(@RequestParam(name = "adIds") String adIds) throws Exception{
         return iOperateAdManageService.publishAd(adIds);
    }

    /**
     * <desc>
     *      批量删除广告信息。
     * <desc/>
     *
     * @param  adIds 广告ID列表
     * @return
     * @author shengen.T
     * @createDate 2017/10/17
     */
    @Override
    @RequestMapping(path="/operate/marketer/ad/deleteAd/{adIds}",method = {RequestMethod.GET})
    public Integer deleteAd(@RequestParam(name = "adIds") String adIds) throws Exception{
        return iOperateAdManageService.deleteAd(adIds);
    }

     /**
      * <desc>
      *      设置状态。
      * <desc/>
      *
      * @param  adId 广告ID
      * @param status 状态
      * @return
      * @author shengen.T
      * @createDate 2017/10/17
      */
    @Override
    @RequestMapping(path="/operate/marketer/ad/setAdStatus/{adId}/{status}",method = {RequestMethod.GET})
    public Integer setAdStatus(@RequestParam(name = "adId") String adId, @RequestParam(name = "status") Integer status) throws Exception{
        return iOperateAdManageService.setAdStatus(adId,status);
    }

     /**
      * <desc>
      *      获取单条广告信息。
      * <desc/>
      *
      * @param  adId
      * @return
      * @author shengen.T
      * @createDate 2017/10/17
      */
    @Override
    @RequestMapping(path="/operate/marketer/ad/getAdInfo/{adId}",method = {RequestMethod.GET})
    public OperateAdGetOneVO getAdInfo(@RequestParam(name = "adId") String adId) throws Exception{
        OperateAdGetOneVO adVO =iOperateAdManageService.getAdInfo(adId);
        return adVO;
    }

     /**
      * <desc>
      *      条件查询广告信息分页列表。
      * <desc/>
      *
      * @param  pageDTO  查询请求参数
      * @return
      * @author shengen.T
      * @createDate 2017/10/17
      */
    @Override
    @RequestMapping(path="/operate/marketer/ad/getAdInfoPage",method = {RequestMethod.POST})
    public Page<OperateAdVO> getAdInfoPage(@RequestBody OperateAdInfoGetPageDTO pageDTO) throws Exception{
        return iOperateAdManageService.getAdInfoPage(pageDTO);
    }

    /**
     * <desc>
     * 获取最新已发布Banner图片列表
     * <desc/>
     *
     * @param projectId 项目id
     * @param type      广告类型（1主页，2服务页，3物业服务页）
     * @param publishPlatform 发布平台（1APP，2小程序）
     * @return
     * @author Chunjian.G
     * @createDate 2017-11-08
     */
    @Override
    @RequestMapping(path="/operate/marketer/ad/getBannerImgs",method = {RequestMethod.POST})
    public List<OperateAdImgVO> getBannerImgs(@RequestParam(name = "projectId") String projectId,
                                               @RequestParam(name = "type") Integer type,
                                              @RequestParam(name = "publishPlatform") Integer publishPlatform) throws Exception {
        return iOperateAdManageService.getBannerImgs(projectId, type,publishPlatform);
    }

    /**
     * <desc>
     *      改变过期的广告的发布状态。
     * <desc/>
     *
     * @param
     * @return
     * @author shengen.T
     * @createDate 2017/11/24
     */
    @Override
    @RequestMapping(path="/operate/marketer/ad/changePublishState")
    public boolean changePublishStateTimeTask() throws Exception{
       return iOperateAdManageService.changePublishStateTimeTask();
    }


    /**
     * <desc>
     *      广告审核通过
     * </desc>
     *
     * @param operateAdInfoGetPageDTO 参数DTO
     * @return
     * @Author Zhu.yj
     * @createDate  2020/12/24
     */
    @Override
    @PostMapping("/operate/marketer/ad/audit")
    public Integer audit(@RequestBody OperateAdInfoGetPageDTO operateAdInfoGetPageDTO) throws Exception {
        return iOperateAdManageService.audit(operateAdInfoGetPageDTO);
    }

}
